From c48e061f677d3f9c59ed543ff0630e926418df5b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Wed, 2 Nov 2016 10:25:40 +0100 Subject: [PATCH] CSSMin: Correctly avoid fallbacks when embedding SVG files The check for file existence before checking its MIME type was building the path incorrectly, causing this piece of code to always think the file does not exist. (The code to actually embed the file was correct.) This was not caught by the tests before of a bug in the test code, which cancelled out this one. Bug: T100958 Change-Id: I4469079f41d48052d0a02f98bb1ed02407abd54c --- includes/libs/CSSMin.php | 2 +- tests/phpunit/includes/libs/CSSMinTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/libs/CSSMin.php b/includes/libs/CSSMin.php index 6e40f4c674..797a438d00 100644 --- a/includes/libs/CSSMin.php +++ b/includes/libs/CSSMin.php @@ -319,7 +319,7 @@ class CSSMin { ); $url = $match['file'] . $match['query']; - $file = $local . $match['file']; + $file = "{$local}/{$match['file']}"; if ( !self::isRemoteUrl( $url ) && !self::isLocalUrl( $url ) && file_exists( $file ) diff --git a/tests/phpunit/includes/libs/CSSMinTest.php b/tests/phpunit/includes/libs/CSSMinTest.php index 5f5a1e8f01..366714b193 100644 --- a/tests/phpunit/includes/libs/CSSMinTest.php +++ b/tests/phpunit/includes/libs/CSSMinTest.php @@ -129,8 +129,8 @@ class CSSMinTest extends MediaWikiTestCase { * @covers CSSMin::remap */ public function testRemapRemapping( $message, $input, $expectedOutput ) { - $localPath = __DIR__ . '/../../data/cssmin/'; - $remotePath = 'http://localhost/w/'; + $localPath = __DIR__ . '/../../data/cssmin'; + $remotePath = 'http://localhost/w'; $realOutput = CSSMin::remap( $input, $localPath, $remotePath ); $this->assertEquals( $expectedOutput, $realOutput, "CSSMin::remap: $message" ); -- 2.20.1